package rgroupmodel

type RGroup struct {
	ID          int    `validate:"min=0"`               // ID
	Name        string `validate:"required"`            // 名字
	Signer      string `validate:"required"`            // 创建者
	Description string `validate:"omitempty"`           // 规则组描述
	UGroupID    int    `db:"ug_id" validate:"required"` // 规则组属于哪个用户组 如果不属于任何用户组设置为-1
}

type GetRGroup struct {
	PageSize int `validate:"required"` // 页尺寸
	PageNo   int `validate:"required"` // 页号
	UGroupID int `validate:"required"` //用户组ID
}

type GetUserRGroup struct {
	PageSize int `validate:"required"` // 页尺寸
	PageNo   int `validate:"required"` // 页号
	UserID   int `validate:"required"` //用户ID
}

type RGroupInfo struct {
	ID   int    `validate:"gt=0,required"`
	Name string `validate:"required"`
}

type GrantUGroup struct {
	RGroupID int    `validate:"gt=0,required"` // 规则组ID
	UGroupID int    `validate:"required"`      // 用户组ID
	Signer   string `validate:"required"`      // 授予者名字
}

type DepriveUGroup struct {
	RGroupID int `validate:"required"` // 规则组ID
	UGroupID int `validate:"required"` // 用户组ID
}

type GrantUser struct {
	RGroupID int    `validate:"gt=0,required"` // 规则组ID, 不能加unique, 否则崩溃
	UserID   int    `validate:"required"`      // 用户组ID
	Signer   string `validate:"required"`      // 授予者名字
}

type DepriveUser struct {
	RGroupID int `validate:"required"` // 规则组ID
	UserID   int `validate:"required"` // 用户ID
}

// GrantRule 分配规则到规则组
type GrantRule struct {
	IDs      []int  `validate:"required,unique,gt=0"` // 规则ID列表
	RGroupID int    `validate:"required"`             // 规则组ID
	Signer   string `validate:"required"`             // 授予者名字
}

// DepriveRule 取消规则到规则组
type DepriveRule struct {
	IDs      []int `validate:"required,unique,gt=0"` // 规则ID列表
	RGroupID int   `validate:"required"`             // 规则组ID
}
